<?php

namespace Modules\Coupon\Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use Modules\Coupon\Entities\CouponActive;
use Modules\Coupon\Entities\Coupon;

class CouponDatabaseSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        Model::unguard();

        // 赠送
        $active = CouponActive::create([
            'title' => '怡宝矿泉水',
            'summary' => '凭此卷可以免费换取一桶怡宝矿泉水',
            'type' => 4,
            'param' => ['goods'=>[['id'=>1, 'quantity'=> 1]]],
            'start_at' => today(),
            'end_at' => today()->addDays(30*3),
        ]);

        for ($i=0; $i < 30; $i++) { 
            
            Coupon::insert([
                [
                    'coupon_active_id' => $active->id,
                    'user_id' => 1,
                    'expired_at' => today()->addDays(365),
                ],
            ]);
            
        }

        // 

        // $this->call("OthersTableSeeder");
    }
}
